<template>
  <div>
    <el-row :gutter="20">
      <el-col :span="8">
        <el-card shadow="hover" class="mgb20">
          <div class="user-info">
            <img :src="$store.getters.getUserInfo.avatar" class="user-avator" alt />
            <div class="user-info-cont">
              <div class="user-info-name">{{ $store.getters.getUserInfo.username }}</div>
              <div>{{ $store.getters.getUserInfo.roles[0] }}</div>
            </div>
          </div>

          <div class="user-info-list">
            <span class="left">电话:</span>
            <span>{{ $store.getters.getUserInfo.phone }}</span>
          </div>
          <div class="user-info-list">
            <span class="left">邮箱:</span>
            <span>{{ $store.getters.getUserInfo.email }}</span>
          </div>
          <div class="user-info-list">
            <span class="left">住址:</span>
            <span>
              {{ $store.getters.getUserInfo.province
              }}{{ $store.getters.getUserInfo.county }}
            </span>
          </div>
        </el-card>

        <el-card shadow="hover">
          <template #header>
            <div class="clearfix">
              <span>语言详情</span>
            </div>
          </template>
          Vue
          <el-progress :text-inside="true" :stroke-width="26" :percentage="49.4" color="#42b983"></el-progress>Java
          <el-progress :text-inside="true" :stroke-width="26" :percentage="29.4" color="#f1e05a"></el-progress>JavaScript
          <el-progress :text-inside="true" :stroke-width="26" :percentage="20.2"></el-progress>HTML 、CSS
          <el-progress :text-inside="true" :stroke-width="26" :percentage="1" color="#f56c6c"></el-progress>
        </el-card>
      </el-col>

      <el-col :span="16">
        <el-row :gutter="20" class="mgb20">
          <el-col :span="8" v-for="(item, index) in showList" :key="index">
            <el-card shadow="hover" :body-style="{ padding: '0px' }">
              <div class="grid-content grid-con-1">
                <i :class="item.icon"></i>
                <div class="grid-cont-right">
                  <div class="grid-num">{{ list[index] }}</div>
                  <div>{{ item.title }}</div>
                </div>
              </div>
            </el-card>
          </el-col>
        </el-row>
        <el-card shadow="hover" style="min-height:403px;">
          <template #header>
            <div class="clearfix">
              <span>项目涉及技术</span>

              <span style="float:right;">
                <a href="https://gitee.com/huang-zhiying/zhxx.git">gitee源码传送门</a>
              </span>
              <span style="float:right;margin-right:15px;">
                <a href="http://120.77.32.140/">项目线上演示</a>
              </span>
            </div>
          </template>

          <el-table :show-header="false" :data="todoList" style="width:100%;">
            <el-table-column prop="title">
              <template slot-scope="scope">
                <div>
                  <span>{{ scope.row.title }}</span>
                  <span style="display: inline-block; margin-left:30px;">{{ scope.row.desc }}</span>
                </div>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
      </el-col>

      <el-col>
        <Echarts :sD="list2" :yD="[]" :xD="xdata" :title="title"></Echarts>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import Echarts from '../common/myEcharts.vue'
export default {
  components: {
    Echarts,
  },
  data() {
    return {
      list: [],
      list2: [],
      todoList: [
        {
          title: '前端：Vue 全家桶',
          desc: 'Vue+Vue-router+Vuex+axios 主流的开发框架拥有丰富的生态圈便于维护',
        },
        {
          title: '移动端框架：vant',
          desc: 'Vant 轻量、可靠的移动端 Vue 组件库 ',
        },
        {
          title: '后端Java框架：Springboot',
          desc: 'Spring BootSpring开源组织下的子项目,只要打成一个可执行的jar包就能独立运行',
        },

        {
          title: '安全框架：Spring Security',
          desc: '强大和高度可定制的身份验证和访问控制框架,证基于spring的应用程序安全的实际标准',
        },
        {
          title: '测试和日志：Junit、Log4j',
          desc: '记录测试和日志，随时查看历史操作记录',
        },

        {
          title: '管理系统框架：Element UI ',
          desc: 'Element UI适合vue开发的后台管理系统框架',
        },
        {
          title: '数据分析：Echart',
          desc: '开源免费的图表库',
        },
        {
          title: '数据存储：Mysql数据库',
          desc: '解决数据存储、用于数据的整理和存放',
        },
        {
          title: '连接池：Druid',
          desc: '阿里开源的数据库连接池,对mysql优化',
        },
        {
          title: '代码托管平台Gitee',
          desc: 'Gitee是开源中国社区推出的基于Git的代码托管服务,方便团队开发',
        },
      ],
      showList: [
        {
          id: 1,
          title: '发起的投票数量',
          icon: 'el-icon-user-solid grid-con-icon',
        },
        {
          id: 2,
          title: '公告数量',
          icon: 'el-icon-tickets grid-con-icon',
        },
        {
          id: 3,
          title: '入驻APP商家',
          icon: 'el-icon-s-data grid-con-icon',
        },
      ],
      title: '各模块数据分析',
      xdata: [
        '社区动态',
        '闲置转让',
        '社区团购',
        '社区借用',
        '寻物启事',
        '实物招领',
        '社区公告',
        '社区投诉',
        '社区缴费',
        '物业报修',
        '入驻APP商家',
        '菜单栏数量',
        '角色数量',
        '用户数量',
        '投票数量',
      ],
    }
  },

  created() {
    this.getCount()
  },

  methods: {
    async getCount() {
      const res = await this.$axios.get('/item/lost/list')
      const res2 = await this.$axios.get('/notice/list')
      const res3 = await this.$axios.get('/shop/list')
      this.list.push(res.data.data.total)
      this.list.push(res2.data.data.total)
      this.list.push(res3.data.data.total)
      const res4 = await this.$axios.get('/index/count')
      console.log(res4.data.data)
      for (const item in res4.data.data) {
        this.list2.push(res4.data.data[item])
      }
      console.log(this.list2)
    },
  },
}
</script>

<style scoped>
.el-row {
  margin-bottom: 20px;
}
.el-card {
  padding: 10px;
}

.grid-content {
  display: flex;
  align-items: center;
  height: 100px;
}

.grid-cont-right {
  flex: 1;
  text-align: center;
  font-size: 14px;
  color: #999;
}

.grid-num {
  font-size: 30px;
  font-weight: bold;
}

.grid-con-icon {
  font-size: 50px;
  width: 100px;
  height: 100px;
  text-align: center;
  line-height: 100px;
  color: #fff;
}

.grid-con-1 .grid-con-icon {
  background: rgb(45, 140, 240);
}

.grid-con-1 .grid-num {
  color: rgb(45, 140, 240);
}

.grid-con-2 .grid-con-icon {
  background: rgb(100, 213, 114);
}

.grid-con-2 .grid-num {
  color: rgb(45, 140, 240);
}

.grid-con-3 .grid-con-icon {
  background: rgb(242, 94, 67);
}

.grid-con-3 .grid-num {
  color: rgb(242, 94, 67);
}

.user-info {
  display: flex;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 2px solid #ccc;
  margin-bottom: 20px;
}

.user-avator {
  width: 120px;
  height: 120px;
  border-radius: 50%;
}

.user-info-cont {
  padding-left: 50px;
  flex: 1;
  font-size: 14px;
  color: #999;
}

.user-info-cont div:first-child {
  font-size: 30px;
  color: #222;
}

.user-info-list {
  font-size: 14px;
  color: #999;
  line-height: 25px;
  display: flex;
}
.user-info-list .left {
  display: inline-block;
  width: 6.125rem;
  margin: 0 10px;
}

.user-info-list span {
  margin-left: 5px;
}

.mgb20 {
  margin-bottom: 20px;
}

.todo-item {
  font-size: 14px;
}

.todo-item-del {
  text-decoration: line-through;
  color: #999;
}

.schart {
  width: 100%;
  height: 300px;
}
</style>
